Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed incorrect calls to to_linked_internal_transform #726

Merged
merged 6 commits into from
Nov 29, 2024

Conversation

torfjelde
Copy link
Member

Came across these isuse when trying the following with JET.jl 👀

julia> using DynamicPPL, Distributions, JET

julia> @model function demo()
           x = Vector{Float64}(undef, 2)
           x[1] ~ Normal()
           x[2] ~ Normal()
           return x
       end
demo (generic function with 4 methods)

julia> model = demo();

julia> vi = DynamicPPL.typed_varinfo(model);

julia> for vn in keys(vi)
           DynamicPPL.set_flag!(vi, vn, "del")
       end^C

julia> f, argtypes = DynamicPPL.DebugUtils.gen_evaluator_call_with_types(model, DynamicPPL.typed_varinfo(model), SamplingContext());

julia> report_call(f, argtypes)
═════ 1 possible error found ═════
┌ demo(__model__::Model{…}, __varinfo__::TypedVarInfo{…}, __context__::SamplingContext{…}) @ Main ./REPL[124]:4
│┌ tilde_assume!!(context::SamplingContext{…}, right::Normal{…}, vn::VarName{…}, vi::TypedVarInfo{…}) @ DynamicPPL /Users/tfjelde/.julia/packages/DynamicPPL/Awq82/src/context_implementations.jl:144
││┌ tilde_assume(context::SamplingContext{…}, right::Normal{…}, vn::VarName{…}, vi::TypedVarInfo{…}) @ DynamicPPL /Users/tfjelde/.julia/packages/DynamicPPL/Awq82/src/context_implementations.jl:52
│││┌ tilde_assume(::Random.TaskLocalRNG, ::DefaultContext, ::SampleFromPrior, ::Normal{…}, ::VarName{…}, ::TypedVarInfo{…}) @ DynamicPPL /Users/tfjelde/.julia/packages/DynamicPPL/Awq82/src/context_implementations.jl:67
││││┌ tilde_assume(::DynamicPPL.IsLeaf, rng::Random.TaskLocalRNG, context::DefaultContext, sampler::SampleFromPrior, right::Normal{…}, vn::VarName{…}, vi::TypedVarInfo{…}) @ DynamicPPL /Users/tfjelde/.julia/packages/DynamicPPL/Awq82/src/context_implementations.jl:72
│││││┌ assume(rng::Random.TaskLocalRNG, sampler::SampleFromPrior, dist::Normal{…}, vn::VarName{…}, vi::TypedVarInfo{…}) @ DynamicPPL /Users/tfjelde/.julia/packages/DynamicPPL/Awq82/src/context_implementations.jl:260
││││││ no matching method found `to_linked_internal_transform(::TypedVarInfo{@NamedTuple{x::DynamicPPL.Metadata{Dict{VarName{:x, Accessors.IndexLens{Tuple{Int64}}}, Int64}, Vector{Normal{Float64}}, Vector{VarName{:x, Accessors.IndexLens{Tuple{Int64}}}}, Vector{Float64}, Vector{Set{DynamicPPL.Selector}}}}, Float64}, ::Normal{Float64})`: f = DynamicPPL.to_linked_internal_transform(vi::TypedVarInfo{@NamedTuple{x::DynamicPPL.Metadata{Dict{…}, Vector{…}, Vector{…}, Vector{…}, Vector{…}}}, Float64}, dist::Normal{Float64})
│││││└────────────────────

@torfjelde
Copy link
Member Author

This raises the quesitons as to whether it would be worth making use of test_call and test_opt from JET.jl for certain cases, e.g. the demo models 👀

Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.38%. Comparing base (ba6e3b8) to head (fda9329).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #726      +/-   ##
==========================================
+ Coverage   86.12%   86.38%   +0.26%     
==========================================
  Files          35       35              
  Lines        4180     4180              
==========================================
+ Hits         3600     3611      +11     
+ Misses        580      569      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coveralls
Copy link

coveralls commented Nov 27, 2024

Pull Request Test Coverage Report for Build 12074785118

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 86.388%

Totals Coverage Status
Change from base Build 12074760593: 0.3%
Covered Lines: 3611
Relevant Lines: 4180

💛 - Coveralls

@mhauru
Copy link
Member

mhauru commented Nov 28, 2024

This raises the quesitons as to whether it would be worth making use of test_call and test_opt from JET.jl for certain cases, e.g. the demo models 👀

I think this would be great.

Also, shouldn't the test suite hit these lines?

@torfjelde
Copy link
Member Author

Also, shouldn't the test suite hit these lines?

It's a weird piece of code that is really never hit. Will add a test for it though.

Also, running JET.report_package I find another bug in that branch. This stuff is really neat.

@torfjelde
Copy link
Member Author

This is just the same errors as mentioned in #725 ; hence it would be nice to get this merged

Copy link
Member

@mhauru mhauru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks Tor

@torfjelde torfjelde merged commit 1110d30 into master Nov 29, 2024
12 of 13 checks passed
@torfjelde torfjelde deleted the torfjelde/minor-bugfixes branch November 29, 2024 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants